<template>
  <div class="app-container">
    <!-- 搜索区域 -->
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="100px"
    >
      <el-form-item label="企业名称" prop="companyName">
        <el-input
          v-model="queryParams.companyName"
          placeholder="请输入企业名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
          <el-option label="未审核" :value="1" />
          <el-option label="已通过" :value="2" />
          <el-option label="未通过" :value="3" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">
          搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">
          重置
        </el-button>
      </el-form-item>
    </el-form>

    <!-- 操作按钮区域 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">
          新增年报
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
        >
          修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
        >
          删除
        </el-button>
      </el-col>
    </el-row>

    <!-- 数据表格 -->
    <el-table
      v-loading="loading"
      :data="reportList"
      @selection-change="handleSelectionChange"
      stripe
      border
      height="calc(100vh - 300px)"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="企业名称" align="left" prop="companyName" min-width="180" />
      <el-table-column label="信用代码" align="center" prop="unifiedSocialCreditCode" width="180" />
      <el-table-column label="状态" align="center" prop="status" width="100">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status === 1" type="warning">未审核</el-tag>
          <el-tag v-if="scope.row.status === 2" type="success">已通过</el-tag>
          <el-tag v-if="scope.row.status === 3" type="danger">未通过</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="成立时间" align="center" prop="establishmentDate" width="120">
        <template slot-scope="scope">
          {{ formatDate(scope.row.establishmentDate) }}
        </template>
      </el-table-column>
<!--      <el-table-column label="注册资本(千元)" align="right" prop="registeredCapital" width="130">-->
<!--        <template slot-scope="scope">-->
<!--          {{ scope.row.registeredCapital.toLocaleString() }}-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="操作" align="center" width="220" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
          >
            详情
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >
            修改
          </el-button>
          <el-button

            size="mini"
            type="text"
            icon="el-icon-check"
            @click="handleAudit(scope.row)"
          >
            审核
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页组件 -->
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.current"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 年报数据表单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="85%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="180px">
        <!-- 企业基本信息 -->
        <el-card shadow="never">
          <div slot="header" class="card-header">
            <span>企业基本信息</span>
          </div>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="企业名称" prop="companyName">
                <el-input v-model="form.companyName" placeholder="请输入企业名称" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="统一社会信用代码" prop="unifiedSocialCreditCode">
                <el-input v-model="form.unifiedSocialCreditCode" placeholder="请输入统一社会信用代码" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="企业成立时间" prop="establishmentDate">
                <el-date-picker
                  v-model="form.establishmentDate"
                  type="date"
                  placeholder="选择成立日期"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="企业入驻时间" prop="settlementDate">
                <el-date-picker
                  v-model="form.settlementDate"
                  type="date"
                  placeholder="选择入驻日期"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="企业登记注册类型" prop="registrationType">
                <el-select v-model="form.registrationType" placeholder="请选择注册类型" style="width: 100%">
                  <el-option label="国有" value="110" />
                  <el-option label="集体" value="120" />
                  <el-option label="股份合作" value="130" />
                  <el-option label="私营" value="171" />
                  <el-option label="港澳台商投资" value="210" />
                  <el-option label="外商投资" value="310" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="所属技术领域" prop="techField">
                <el-select v-model="form.techField" placeholder="请选择技术领域" style="width: 100%">
                  <el-option v-for="item in techFields" :key="item.value" :label="item.label" :value="item.value" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="核心技术领域" prop="keyTechField">
                <el-input v-model="form.keyTechField" placeholder="请输入核心技术领域代码" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="行业类别代码" prop="industryCategory">
                <el-input v-model="form.industryCategory" placeholder="请输入行业类别代码" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="是否与创业导师建立辅导关系" prop="mentorshipRelation">
                <el-radio-group v-model="form.mentorshipRelation">
                  <el-radio :label="1">是</el-radio>
                  <el-radio :label="0">否</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="企业纳税人类型" prop="taxpayerType">
                <el-radio-group v-model="form.taxpayerType">
                  <el-radio :label="1">一般纳税人</el-radio>
                  <el-radio :label="0">小规模纳税人</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="主要负责人性别" prop="principalGender">
                <el-radio-group v-model="form.principalGender">
                  <el-radio :label="1">男</el-radio>
                  <el-radio :label="0">女</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <!-- 企业资质信息 -->
        <el-card shadow="never" class="mt-20">
          <div slot="header" class="card-header">
            <span>企业资质信息</span>
          </div>
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="是否毕业企业" prop="isGraduated">
                <el-radio-group v-model="form.isGraduated">
                  <el-radio :label="1">是</el-radio>
                  <el-radio :label="0">否</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="是否高新技术企业" prop="isHighTech">
                <el-radio-group v-model="form.isHighTech">
                  <el-radio :label="1">是</el-radio>
                  <el-radio :label="0">否</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item v-if="form.isHighTech === 1" label="高企证书编号" prop="highTechCertNo">
                <el-input v-model="form.highTechCertNo" placeholder="请输入高企证书编号" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="是否科技型中小企业" prop="isTechSme">
                <el-radio-group v-model="form.isTechSme">
                  <el-radio :label="1">是</el-radio>
                  <el-radio :label="0">否</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item v-if="form.isTechSme === 1" label="科技中小企业登记编码" prop="techSmeRegCode">
                <el-input v-model="form.techSmeRegCode" placeholder="请输入登记编码" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="是否创新型中小企业" prop="isInnovativeSme">
                <el-radio-group v-model="form.isInnovativeSme">
                  <el-radio :label="1">是</el-radio>
                  <el-radio :label="0">否</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="是否专精特新中小企业" prop="isSpecializedSme">
                <el-radio-group v-model="form.isSpecializedSme">
                  <el-radio :label="1">是</el-radio>
                  <el-radio :label="0">否</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="是否专精特新小巨人" prop="isLittleGiant">
                <el-radio-group v-model="form.isLittleGiant">
                  <el-radio :label="1">是</el-radio>
                  <el-radio :label="0">否</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <!-- 投融资与场地信息 -->
        <el-card shadow="never" class="mt-20">
          <div slot="header" class="card-header">
            <span>投融资与场地信息（单位：千元）</span>
          </div>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="获得投融资金额" prop="financingAmount">
                <el-input-number
                  v-model="form.financingAmount"
                  :min="0"
                  :controls="false"
                  placeholder="请输入金额"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="孵化基金投资额" prop="incubatorFundInvestment">
                <el-input-number
                  v-model="form.incubatorFundInvestment"
                  :min="0"
                  :controls="false"
                  placeholder="请输入金额"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="银行贷款额" prop="bankLoan">
                <el-input-number
                  v-model="form.bankLoan"
                  :min="0"
                  :controls="false"
                  placeholder="请输入金额"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="注册资本" prop="registeredCapital">
                <el-input-number
                  v-model="form.registeredCapital"
                  :min="0"
                  :controls="false"
                  placeholder="请输入金额"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="占用场地面积(㎡)" prop="occupyingArea">
                <el-input-number
                  v-model="form.occupyingArea"
                  :min="0"
                  :controls="false"
                  placeholder="请输入面积"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <!-- 经济概况 -->
        <el-card shadow="never" class="mt-20">
          <div slot="header" class="card-header">
            <span>经济概况（单位：千元）</span>
          </div>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="企业总收入" prop="totalIncome">
                <el-input-number
                  v-model="form.totalIncome"
                  :min="0"
                  :controls="false"
                  placeholder="请输入金额"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="净利润" prop="netProfit">
                <el-input-number
                  v-model="form.netProfit"
                  :min="0"
                  :controls="false"
                  placeholder="请输入金额"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="出口总额" prop="exportVolume">
                <el-input-number
                  v-model="form.exportVolume"
                  :min="0"
                  :controls="false"
                  placeholder="请输入金额"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="R&D经费支出" prop="rdExpenditure">
                <el-input-number
                  v-model="form.rdExpenditure"
                  :min="0"
                  :controls="false"
                  placeholder="请输入金额"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="实际上缴税费" prop="taxPayment">
                <el-input-number
                  v-model="form.taxPayment"
                  :min="0"
                  :controls="false"
                  placeholder="请输入金额"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <!-- 从业人员情况 -->
        <el-card shadow="never" class="mt-20">
          <div slot="header" class="card-header">
            <span>从业人员情况（单位：人）</span>
          </div>
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="从业人员总数" prop="employees">
                <el-input-number
                  v-model="form.employees"
                  :min="0"
                  :controls="false"
                  placeholder="请输入人数"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="博士人数" prop="doctorNum">
                <el-input-number
                  v-model="form.doctorNum"
                  :min="0"
                  :controls="false"
                  placeholder="请输入人数"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="大专以上人数" prop="collegeAbove">
                <el-input-number
                  v-model="form.collegeAbove"
                  :min="0"
                  :controls="false"
                  placeholder="请输入人数"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="吸纳应届毕业生" prop="freshGraduate">
                <el-input-number
                  v-model="form.freshGraduate"
                  :min="0"
                  :controls="false"
                  placeholder="请输入人数"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="留学人员" prop="returnee">
                <el-input-number
                  v-model="form.returnee"
                  :min="0"
                  :controls="false"
                  placeholder="请输入人数"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <!-- 知识产权情况 -->
        <el-card shadow="never" class="mt-20">
          <div slot="header" class="card-header">
            <span>知识产权情况</span>
          </div>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="知识产权申请数(件)" prop="ipApplication">
                <el-input-number
                  v-model="form.ipApplication"
                  :min="0"
                  :controls="false"
                  placeholder="请输入数量"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="知识产权授权数(件)" prop="ipGranted">
                <el-input-number
                  v-model="form.ipGranted"
                  :min="0"
                  :controls="false"
                  placeholder="请输入数量"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="发明专利授权数(件)" prop="inventionPatentGranted">
                <el-input-number
                  v-model="form.inventionPatentGranted"
                  :min="0"
                  :controls="false"
                  placeholder="请输入数量"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="有效知识产权数(件)" prop="validIp">
                <el-input-number
                  v-model="form.validIp"
                  :min="0"
                  :controls="false"
                  placeholder="请输入数量"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="有效发明专利数(件)" prop="validInventionPatent">
                <el-input-number
                  v-model="form.validInventionPatent"
                  :min="0"
                  :controls="false"
                  placeholder="请输入数量"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="软件著作权(件)" prop="softwareCopyright">
                <el-input-number
                  v-model="form.softwareCopyright"
                  :min="0"
                  :controls="false"
                  placeholder="请输入数量"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="植物新品种(个)" prop="plantVariety">
                <el-input-number
                  v-model="form.plantVariety"
                  :min="0"
                  :controls="false"
                  placeholder="请输入数量"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="集成电路布图(个)" prop="icLayout">
                <el-input-number
                  v-model="form.icLayout"
                  :min="0"
                  :controls="false"
                  placeholder="请输入数量"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="购买国外专利(件)" prop="foreignPatentPurchase">
                <el-input-number
                  v-model="form.foreignPatentPurchase"
                  :min="0"
                  :controls="false"
                  placeholder="请输入数量"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <!-- 技术合同与科技项目 -->
        <el-card shadow="never" class="mt-20">
          <div slot="header" class="card-header">
            <span>技术合同与科技项目</span>
          </div>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="技术合同数量(项)" prop="techContractNum">
                <el-input-number
                  v-model="form.techContractNum"
                  :min="0"
                  :controls="false"
                  placeholder="请输入数量"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="技术合同成交额(千元)" prop="techContractAmount">
                <el-input-number
                  v-model="form.techContractAmount"
                  :min="0"
                  :controls="false"
                  placeholder="请输入金额"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="国家级科技项目数(项)" prop="nationalTechProject">
                <el-input-number
                  v-model="form.nationalTechProject"
                  :min="0"
                  :controls="false"
                  placeholder="请输入数量"
                  style="width: 100%"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 审核对话框 -->
    <el-dialog :title="'审核 - ' + auditForm.companyName" :visible.sync="auditOpen" width="600px" append-to-body>
      <el-form ref="auditForm" :model="auditForm"  label-width="120px">
        <el-form-item label="审核状态">
          <el-radio-group v-model="auditForm.status">
            <el-radio :label="2">通过</el-radio>
            <el-radio :label="3">不通过</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelAudit">取 消</el-button>
        <el-button type="primary" @click="submitAudit">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  AddHatchyearData,
  UpdataUserHatchyearData,
  HatchyearDatadetial,
  DelHatchyearData,
  GetUserHatchyearDataStatusGT0
} from '@/api/system/DataFrom';

export default {
  name: "HatchyearData",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 报表列表
      reportList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示审核弹窗
      auditOpen: false,
      // 技术领域选项
      techFields: [
        {value: '1', label: '电子信息'},
        {value: '2', label: '先进制造'},
        {value: '3', label: '航空航天'},
        {value: '4', label: '现代交通'},
        {value: '5', label: '生物医药与医疗器械'},
        {value: '6', label: '新材料'},
        {value: '7', label: '新能源与节能'},
        {value: '8', label: '环境保护'},
        {value: '9', label: '地球、空间与海洋'},
        {value: '10', label: '核应用技术'},
        {value: '11', label: '现代农业'},
        {value: '12', label: '文化创意'}
      ],
      // 查询参数
      queryParams: {
        current: 1,
        pageSize: 10,
        companyName: null,
        status: null
      },
      // 表单参数
      form: {},
      // 审核表单参数
      auditForm: {
        id: null,
        status: null,
        reportDate: null,
        companyName: null,
        companyPrincipal: null,
        statisticsPrincipal: null,
        filler: null,
        contactPhone: null
      },
      // 表单验证规则
      rules: {
        companyName: [
          {required: true, message: "企业名称不能为空", trigger: "blur"}
        ],
        unifiedSocialCreditCode: [
          {required: true, message: "统一社会信用代码不能为空", trigger: "blur"}
        ],
        establishmentDate: [
          {required: true, message: "企业成立时间不能为空", trigger: "blur"}
        ],
        settlementDate: [
          {required: true, message: "企业入驻时间不能为空", trigger: "blur"}
        ],
        registrationType: [
          {required: true, message: "企业登记注册类型不能为空", trigger: "blur"}
        ],
        techField: [
          {required: true, message: "企业所属技术领域不能为空", trigger: "blur"}
        ]
      },
      // 审核表单验证规则


    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询报表列表 */
    getList() {
      this.loading = true;
      GetUserHatchyearDataStatusGT0(this.queryParams).then(response => {
        this.reportList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },

    /** 日期格式化 */
    formatDate(date) {
      if (!date) return '';
      return date.split('T')[0];
    },

    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },

    // 审核取消按钮
    cancelAudit() {
      this.auditOpen = false;
      this.resetAudit();
    },

    // 表单重置
    reset() {
      this.form = {
        id: null,
        companyName: null,
        unifiedSocialCreditCode: null,
        establishmentDate: null,
        settlementDate: null,
        registrationType: null,
        techField: null,
        keyTechField: null,
        industryCategory: null,
        mentorshipRelation: 0,
        taxpayerType: 1,
        principalGender: 1,
        isGraduated: 0,
        isMergedAcquired: 0,
        isListed: 0,
        entrepreneurType: null,
        isHighTech: 0,
        highTechCertNo: null,
        isTechSme: 0,
        techSmeRegCode: null,
        isInnovativeSme: 0,
        isSpecializedSme: 0,
        isLittleGiant: 0,
        financingAmount: 0,
        incubatorFundInvestment: 0,
        bankLoan: 0,
        occupyingArea: 0,
        registeredCapital: 0,
        totalIncome: 0,
        netProfit: 0,
        exportVolume: 0,
        rdExpenditure: 0,
        taxPayment: 0,
        employees: 0,
        doctorNum: 0,
        collegeAbove: 0,
        freshGraduate: 0,
        returnee: 0,
        ipApplication: 0,
        ipGranted: 0,
        inventionPatentGranted: 0,
        validIp: 0,
        validInventionPatent: 0,
        softwareCopyright: 0,
        plantVariety: 0,
        icLayout: 0,
        foreignPatentPurchase: 0,
        techContractNum: 0,
        techContractAmount: 0,
        nationalTechProject: 0
      };
      this.resetForm("form");
    },

    // 审核表单重置
    resetAudit() {
      this.auditForm = {
        id: null,
        status: null,
        reportDate: null,
        companyName: null,
        companyPrincipal: null,
        statisticsPrincipal: null,
        filler: null,
        contactPhone: null
      };
      this.resetForm("auditForm");
    },

    /** 搜索按钮功能 */
    handleQuery() {
      this.queryParams.current = 1;
      this.getList();
    },

    /** 重置按钮功能 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },

    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加科技孵化器年报";
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      HatchyearDatadetial(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改科技孵化器年报";
      });
    },

    /** 查看详情 */
    handleView(row) {
      this.reset();
      const id = row.id;
      HatchyearDatadetial(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "查看科技孵化器年报详情";
        // 设置为只读模式
        this.$nextTick(() => {
          const formElements = this.$refs.form.$el.querySelectorAll('input, select, textarea, button');
          formElements.forEach(el => {
            el.setAttribute('disabled', true);
          });
        });
      });
    },

    /** 审核按钮操作 */
    handleAudit(row) {
      this.resetAudit();
      this.auditForm.id = row.id;
      this.auditForm.companyName = row.companyName;
      this.auditOpen = true;
    },

    /** 提交审核 */
    submitAudit() {
      this.$refs["auditForm"].validate(valid => {
        if (valid) {
          const data = {
            id: this.auditForm.id,
            status: this.auditForm.status,
            // reportDate: this.auditForm.reportDate,
            // companyName: this.auditForm.companyName,
            // companyPrincipal: this.auditForm.companyPrincipal,
            // statisticsPrincipal: this.auditForm.statisticsPrincipal,
            // filler: this.auditForm.filler,
            // contactPhone: this.auditForm.contactPhone
          };
          UpdataUserHatchyearData(data).then(response => {
            this.$modal.msgSuccess("审核成功");
            this.auditOpen = false;
            this.getList();
          });
        }
      });
    },

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            UpdataUserHatchyearData(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            // 新增时默认状态为未审核（1）
            this.form.status = 1;
            AddHatchyearData(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },

    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除所选的年报数据？').then(() => {
        return DelHatchyearData(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    }
  }
};
</script>

<style scoped>
.app-container {
  padding: 20px;
  background: #f5f7fa;
}

.card-header {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  display: flex;
  align-items: center;
}

.card-header::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 16px;
  background: #409EFF;
  margin-right: 10px;
  border-radius: 2px;
}

.mt-20 {
  margin-top: 20px;
}

.dialog-footer {
  text-align: right;
  padding: 20px 0 0;
}

.el-card {
  margin-bottom: 20px;
  border-radius: 8px;
  border: 1px solid #ebeef5;
}

.el-row {
  margin-bottom: 10px;
}

:deep(.el-form-item) {
  margin-bottom: 18px;
}

:deep(.el-input-number) {
  width: 100%;
}

:deep(.el-input-number .el-input__inner) {
  text-align: left;
}
</style>
